package app.beit.finportal.entity;

import java.util.Arrays;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@SuppressWarnings("serial")
@Entity
@Table(name="fin_news")
@SequenceGenerator(allocationSize=1, name="seqHibernateName", sequenceName="seq_fin_news")
public class News extends BaseEntity {

	@Column(name="picture", nullable=false)
	@Lob
	private byte[] picture;
	
	@Column(name="name", length=100, nullable=false)
	private String name;
	
	@Column(name="description", length=2000)
	private String description;
	
	@Column(name="status", nullable=false, precision=1, scale=0)
	private Integer status;
	
	@Column(name="url", length=200)
	private String url;

	@Column(name="picture_location", length=200)
	private String pictureLocation;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="created_by", referencedColumnName="username", insertable=false, updatable=false)
	private Account createdAccount;
	
	@ManyToOne(fetch=FetchType.LAZY)
	@JoinColumn(name="updated_by", referencedColumnName="username", insertable=false, updatable=false)
	private Account updatedAccount;

	public Account getCreatedAccount() {
		return createdAccount;
	}

	public void setCreatedAccount(Account createdAccount) {
		this.createdAccount = createdAccount;
	}

	public Account getUpdatedAccount() {
		return updatedAccount;
	}

	public void setUpdatedAccount(Account updatedAccount) {
		this.updatedAccount = updatedAccount;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public byte[] getPicture() {
		return picture;
	}

	public void setPicture(byte[] picture) {
		this.picture = picture;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getPictureLocation() {
		return pictureLocation;
	}

	public void setPictureLocation(String pictureLocation) {
		this.pictureLocation = pictureLocation;
	}

	@Override
	public String toString() {
		return "News [picture=" + Arrays.toString(picture) + ", name=" + name
				+ ", description=" + description + ", status=" + status
				+ ", url=" + url + ", pictureLocation=" + pictureLocation + "]";
	}

}
